package cn.uniqueww.javadesignpatterns.demos.design.fstGroup;

import org.springframework.stereotype.Component;

/**
 * VIP用户打折
 *
 * @since 2024/1/17 11:35 上午
 */
@Component
public class VIPUser extends ComputedAmount{
    /**
     * 计算金额
     *
     * @param price   单价
     * @param count   数量
     * @return 打折后的金额
     */
    @Override
    public double computedAmount(int price, int count) {
        return UserType.VIP.getDiscount() * price * count;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        UserComputedAmountFactory.register(UserType.VIP, this);
    }
}
